package com.qk.management.mapper;

import com.qk.entity.Course;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 *
 * @author lyl
 * @created 2025/10/9 14:35
 * @description
 *
 */
@Mapper
public interface CourseMapper {

    List<Course> getListByPage(@Param("name") String name,@Param("subject") Integer subject,@Param("target") Integer target);

    @Insert("INSERT INTO  course(name, subject, price, target, description, create_time, update_time) values(#{name}, #{subject}, #{price}, #{target}, #{description}, #{createTime}, #{updateTime})")
    void add(Course course);

    @Delete("DELETE FROM course WHERE id=#{id}")
    void delete(Integer id);

    @Select("SELECT id, name, subject, price, target, description, create_time, update_time FROM course WHERE id= #{id}")
    Course getCourseById(Integer id);

    @Update("UPDATE course SET name= #{name}, subject= #{subject}, price= #{price}, target= #{target}, description= #{description}, update_time= #{updateTime} WHERE id= #{id}")
    void update(Course course);

    @Select("SELECT id, name, subject, price, target, description, create_time, update_time FROM course")
    List<Course> getAllList();

    @Select("SELECT id, name, subject, price, target, description, create_time, update_time FROM course WHERE subject= #{subject}")
    List<Course> getListBySubject(Integer subject);
}
